
<#include "*/general/header.ftl">
<h3>Shopping Cart</h3>
<#assign total = 0/>
<#assign count = 0/>

<table class="supa">
    <tr>
      <th scope="col" class="nobg">Product Name</th> 
      <th scope="col">Description</th>
      <th scope="col">Price</th>
      <th scope="col">Quantity</th> 
      <th scope="col">Cost</th>
    </tr>  

    <form action = "cart.action" method = "post">

        <#list pmap?keys as pro>

        <#assign price = "${pro.price}"/>
        <#assign quant = "${pmap.get(pro)}"/>
        <#assign x = price?number*quant?number/>
        <#assign count = count + quant?number/>
        <#assign total = total+ x/>&nbsp

        <tr><input type = "hidden" name = "productid" value = "${pro.product_id}"/>
            <th scope="row" class="spec">${pro.name}</th>
            <td>${pro.description}</td>
            <td>$${pro.price}</td>
            <td><input class="niceinput" type = "text" name= "quantity" value =  "${quant}"</td>
            <td>$${x}</td>
        </tr>
        </#list>

        <tr>
            <td class="bottom" colspan="2"><span class="blue">Please enter the quantity "0" to remove product from shopping cart.</span></td>
            <td class="bottom"><input type = "submit" value="Update" onClick="Submit"/></td>
            <th scope="row" class="nobg bottom">Total Amount:</th>
            <td class="bottom bold">$${total}</td>
        </tr>

    </form>

    <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
        <input type="hidden" name="cmd" value="_cart">
        <input type="hidden" name="upload" value="1">
        <input type="hidden" name="business" value="usman_nisar1984@hotmail.com">
        <input type="hidden" name="lc" value="US">
        <input type="hidden" name="button_subtype" value="services">
        <input type="hidden" name="no_note" value="1">
        <input type="hidden" name="currency_code" value="USD">
        <input type="hidden" name="tax_rate" value="7.000">

        <#assign x = 1/>
        <#list pmap?keys as pro>
            <input type="hidden" name="item_name_${x}" value="${pro.name}">
            <input type="hidden" name="amount_${x}" value="${pro.price}">    
            <input type="hidden" name="quantity_${x}" value="${pmap.get(pro)}">
        <#assign x = x+1/>
        </#list>

        <input type="hidden" name="cancel_return" value="http://localhost:8080/Carrello/">
        <input type="hidden" name="return" value="http://localhost:8080/Carrello/checkout.action?success=1">
        <input type="hidden" name="bn" value="PP-BuyNowBF:btn_buynowCC_LG.gif:NonHostedGuest">
        <input name="amount" type="hidden" id="amount" size="45" value="${total}">
        
        <tr>
            <td class="bottom fright" colspan="5">
                <input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_buynowCC_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
                <img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
            </td>
        </tr>
 
    </form>

</table>

<#include "*/general/footer.ftl">